<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.reapal.utils.*"%>
<%@ page import="com.reapal.config.*"%>
<%@ page import="com.alibaba.fastjson.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>融宝快捷储蓄卡签约接口</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	    <style type="text/css">
<!--
.STYLE1 {
	font-size: 10px;
	font-weight: bold;
}
.STYLE3 {font-size: 16px}
.STYLE4 {
	font-size: large;
	font-weight: bold;
}
.form-star {
	PADDING-RIGHT: 0px; PADDING-LEFT: 3px; FONT-SIZE: 12px; PADDING-BOTTOM: 3px; VERTICAL-ALIGN: top; WIDTH: 1%; COLOR: #ff0000; PADDING-TOP: 12px
}
-->
    </style>
  </head>
<%
	String key = ReapalConfig.key;
	String merchantId = request.getParameter("merchant_id");
	String data = request.getParameter("data");
	String encryptkey = request.getParameter("encryptkey");
	
	System.out.println("merchantIdmerchantI========" + merchantId);
	System.out.println("datadatadatadatadata========" + data);
	System.out.println("encryptkeyencryptkeyencryptkey========" + encryptkey);
	
	//解析密文数据
	String decryData = Decipher.decryptData(encryptkey, data);
	System.out.println("decryDatadecryDatadecryDatadecryData========" + decryData);
	//获取融宝支付的通知返回参数
	JSONObject jsonObject = JSON.parseObject(decryData);
	System.out.println("jsonObjectjsonObjectjsonObjectjsonObject========" + jsonObject);
	String merchant_id = jsonObject.getString("merchant_id");
	String trade_no = jsonObject.getString("trade_no");
	String order_no = jsonObject.getString("order_no");
	String result_code = jsonObject.getString("result_code");
	String result_msg = jsonObject.getString("result_msg");
	String sign = jsonObject.getString("sign");
	String card_last = jsonObject.getString("card_last");
	String bind_id = jsonObject.getString("bind_id");
	String bank_code = jsonObject.getString("bank_code");
	String bank_name = jsonObject.getString("bank_name");
	String member_id = jsonObject.getString("member_id");
	String bank_card_type = jsonObject.getString("bank_card_type");
	String phone = jsonObject.getString("phone");
	String total_fee = jsonObject.getString("total_fee");

	Map<String, String> map = new HashMap<String, String>();
	map.put("merchant_id", merchant_id);
	map.put("trade_no", trade_no);
	map.put("order_no", order_no);
	map.put("result_code", result_code);
	map.put("result_msg", result_msg);
	map.put("bind_id", bind_id);
	map.put("card_last", card_last);
	map.put("bank_code", bank_code);
	map.put("bank_name", bank_name);
	map.put("member_id", member_id);
	map.put("bank_card_type", bank_card_type);
	map.put("phone", phone);
	map.put("total_fee", total_fee);
	
	//将返回的参数进行验签
	String mysign = Md5Utils.BuildMysign(map, key);

	System.out.println("mysign:" + mysign);
	System.out.println("sign:" + sign);

	//建议校验responseTxt，判读该返回结果是否由融宝发出
	if (mysign.equals(sign)) {
		out.write("success");
		//编写业务逻辑代码
		System.out.println("***************************************收到异步通讯");
	}
%>

<body>
	<%=jsonObject%>
</body>
</html>
